<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"fengxun2017.github.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.13.2","exturl":false,"sidebar":{"position":"right","display":"hide","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>

    <meta name="description" content="FreeRTOS提供了信号量功能，通过使用信号量，可以实现任务和任务、中断服务函数和任务间的事件&#x2F;信息同步。本文最后，还解释了为了什么FreeRTOS有两套API分别在中断&#x2F;非中断环境下使用。">
<meta property="og:type" content="article">
<meta property="og:title" content="FreeRTOS-使用二值信号量">
<meta property="og:url" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/index.html">
<meta property="og:site_name" content="fx">
<meta property="og:description" content="FreeRTOS提供了信号量功能，通过使用信号量，可以实现任务和任务、中断服务函数和任务间的事件&#x2F;信息同步。本文最后，还解释了为了什么FreeRTOS有两套API分别在中断&#x2F;非中断环境下使用。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/task_sync.png">
<meta property="og:image" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/binary-create.png">
<meta property="og:image" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/binary-give.png">
<meta property="og:image" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/binary-take.png">
<meta property="article:published_time" content="2022-12-14T16:00:00.000Z">
<meta property="article:modified_time" content="2023-02-13T16:39:12.512Z">
<meta property="article:author" content="feng xun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/task_sync.png">


<link rel="canonical" href="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/","path":"2022/12/15/FreeRTOS-use-binary-semaphore/","title":"FreeRTOS-使用二值信号量"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>FreeRTOS-使用二值信号量 | fx</title>
  






  <script async defer data-website-id="" src=""></script>

  <script defer data-domain="" src=""></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
  <a target="_blank" rel="noopener" href="https://github.com/fengxun2017" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">fx</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">FreeRTOS交流QQ群-663806972 BLE学习交流群-498676838</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E4%BF%A1%E5%8F%B7%E9%87%8F%E7%9A%84%E4%BD%9C%E7%94%A8%EF%BC%9A"><span class="nav-number">1.</span> <span class="nav-text">1 信号量的作用：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E4%BA%8C%E5%80%BC%E4%BF%A1%E5%8F%B7%E9%87%8F%EF%BC%9A"><span class="nav-number">2.</span> <span class="nav-text">2 二值信号量：</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#2-1-%E5%88%9B%E5%BB%BA%E4%BA%8C%E5%80%BC%E4%BF%A1%E5%8F%B7%E9%87%8F"><span class="nav-number">2.1.</span> <span class="nav-text">2.1 创建二值信号量</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-2-%E8%AE%BE%E7%BD%AE%E4%BA%8C%E5%80%BC%E4%BF%A1%E5%8F%B7%E9%87%8F%E4%B8%BA%E5%8F%AF%E7%94%A8%E7%8A%B6%E6%80%81"><span class="nav-number">2.2.</span> <span class="nav-text">2.2 设置二值信号量为可用状态</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-3-%E8%8E%B7%E5%8F%96%E4%BF%A1%E5%8F%B7%E9%87%8F"><span class="nav-number">2.3.</span> <span class="nav-text">2.3 获取信号量</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-%E4%BB%BB%E5%8A%A1%E5%92%8C%E4%BB%BB%E5%8A%A1%E9%97%B4%E4%BD%BF%E7%94%A8%E4%BA%8C%E5%80%BC%E4%BF%A1%E5%8F%B7%E9%87%8F%E8%BF%9B%E8%A1%8C%E4%BF%A1%E6%81%AF%E5%90%8C%E6%AD%A5"><span class="nav-number">3.</span> <span class="nav-text">3 任务和任务间使用二值信号量进行信息同步</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-%E4%B8%AD%E6%96%AD%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0%E5%92%8C%E4%BB%BB%E5%8A%A1%E9%97%B4%E4%BD%BF%E7%94%A8%E4%BA%8C%E5%80%BC%E4%BF%A1%E5%8F%B7%E9%87%8F%E8%BF%9B%E8%A1%8C%E4%BF%A1%E6%81%AF%E5%90%8C%E6%AD%A5"><span class="nav-number">4.</span> <span class="nav-text">4 中断处理函数和任务间使用二值信号量进行信息同步</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88FreeRTOS%E4%B8%AD%EF%BC%8C%E6%9C%89%E4%B8%A4%E5%A5%97API%E5%88%86%E5%88%AB%E5%9C%A8%E4%B8%AD%E6%96%AD-x2F-%E9%9D%9E%E4%B8%AD%E6%96%AD%E7%8E%AF%E5%A2%83%E4%B8%8B%E4%BD%BF%E7%94%A8%EF%BC%9A"><span class="nav-number">5.</span> <span class="nav-text">为什么FreeRTOS中，有两套API分别在中断&#x2F;非中断环境下使用：</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">feng xun</p>
  <div class="site-description" itemprop="description">FreeRTOS交流QQ群-663806972 BLE学习交流群-498676838</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">96</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">16</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="cc-license site-overview-item animated" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="https://cdnjs.cloudflare.com/ajax/libs/creativecommons-vocabulary/2020.11.3/assets/license_badges/small/by_nc_sa.svg" alt="Creative Commons"></a>
  </div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="feng xun">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="fx">
      <meta itemprop="description" content="FreeRTOS交流QQ群-663806972 BLE学习交流群-498676838">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="FreeRTOS-使用二值信号量 | fx">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          FreeRTOS-使用二值信号量
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-12-15 00:00:00" itemprop="dateCreated datePublished" datetime="2022-12-15T00:00:00+08:00">2022-12-15</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/FreeRTOS/" itemprop="url" rel="index"><span itemprop="name">FreeRTOS</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>7.2k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>9 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <center>
FreeRTOS提供了信号量功能，通过使用信号量，可以实现任务和任务、中断服务函数和任务间的事件/信息同步。本文最后，还解释了为了什么FreeRTOS有两套API分别在中断/非中断环境下使用。
</center>

<span id="more"></span>

<hr>
<h4 id="1-信号量的作用："><a href="#1-信号量的作用：" class="headerlink" title="1 信号量的作用："></a>1 信号量的作用：</h4><p>信号量的核心功能是用来进行任务间的“事件&#x2F;信息同步”，使得多个任务可以按照“期望”的顺序进行运行。例如，任务B执行的工作，依赖于任务A的产出结果，那么就需要将<code>任务A运行完成</code>这个“信息”和任务B进行同步。<br><img src="/2022/12/15/FreeRTOS-use-binary-semaphore/task_sync.png"><br>又如，每当按键按下时，任务C 需要针对性的做一些处理工作，这里就需要将<code>按键按下</code>这个“信事件同步给任务C。</p>
<p>因此，信号量存在两种状态。<code>“可用”</code>状态和<code>“不可用”</code>状态。当我们<strong>获取</strong>某个信号量时，如果信号量当前<code>可用</code>，就可以立刻获取到信号量，否则任务就会进入阻塞状态（取决于是否愿意等待，如果设置了不等待，则立刻返回错误），以等待信号量变为<code>可用</code>。此时如果另一个任务（或中断处理函数）中<strong>设置</strong>了该信号量，那么等待该信号量的任务就会从阻塞态恢复为就绪态。</p>
<p>以之前的例子解释：任务B每次执行的工作，都依赖于任务A 的产出结果<br>假设我们创建了一个信号量<code>semaphore</code>（初始状态<code>不可用</code>），那么任务B 运行后就第一件事就是先<strong>获取</strong><code>semaphore</code>，此时<code>semaphore</code>不可用（期望的事件还没发生），则任务B进入阻塞态。当某个时刻，任务A运行结束了，则任务A 在结束后<strong>设置</strong><code>semaphore</code>（信号量变为可用，将任务A 结束的消息通知给任务B）。之后，由于<code>semaphore</code>变为<code>可用</code>状态，则等待该信号量的任务B 从阻塞状态中恢复为就绪状态，并可以获取到信号量。当任务B也执行完工作后，会再次尝试<strong>获取</strong><code>semaphore</code>，由于<code>semaphore</code>已经被消耗了，那么任务B 再次进入阻塞状态，以等待任务A 再一次完成它的工作，并<strong>设置</strong><code>semaphore</code>（通知B可以运行）。<br>代码逻辑如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">TASK_A:</span><br><span class="line">    <span class="keyword">while</span> <span class="number">1</span>:</span><br><span class="line">        <span class="keyword">do</span> something</span><br><span class="line">        give semaphore  <span class="comment">// 设置信号量，通知任务B，可以运行了</span></span><br><span class="line"></span><br><span class="line">TASK_B:</span><br><span class="line">    <span class="keyword">while</span> <span class="number">1</span>:</span><br><span class="line">        take semaphore  <span class="comment">// 获取信号量，等待任务A 先完成</span></span><br><span class="line">        <span class="keyword">do</span> something</span><br></pre></td></tr></table></figure>

<p>生活中的红绿灯，是个更直观地解释信号量的例子。当红灯亮时（信号量不可用），汽车不允许通过（任务阻塞了）；当绿灯亮时（信号量可用），则恢复运行。</p>
<p>红绿灯这个例子，也隐含了信号量的另一个作用，可以用来对竞争资源进行互斥访问。 十字路口就是竞争资源，任何时刻只能一个方向的汽车通行，当某个方向绿灯了（可以认为这个方向获取到了信号量，可以通行），则另一个方向就是红灯（这个方向没获取到信号量，就不能通行）。但通常开发中，<strong>信号量都是用来进行任务间的“信息&#x2F;事件”同步。对竞争资源的互斥访问，基本都是使用互斥量（mutex）</strong>。顾名思义，<a href="https://fengxun2017.github.io/2023/01/03/FreeRTOS-mutex/">互斥量</a> 就是用来保证数据的互斥访问，让其任意时刻，只能被一个任务访问。对竞争数据的互斥访问，互斥量除了在语义上比信号量更明确外，互斥量还具有优先级继承特性，相对于信号量更适合做数据的互斥访问。</p>
<p>在文章<a href="https://fengxun2017.github.io/2022/12/12/FreeRTOS-use-queue/">FreeRTOS-使用消息队列</a>和文章<a href="https://fengxun2017.github.io/2022/12/08/FreeRTOS-queue-internal-details/">FreeRTOS-消息队列内部细节</a>中，我们学习到了FreeRTOS消息队列的几个特性：</p>
<ul>
<li>FreeRTOS的消息队列是多任务安全的，多个任务同时读写消息队列，不会造成消息队列内部状态错误，消息队列模块内部对读&#x2F;写做了临界区保护。</li>
<li>消息队列为空时，任务请求从消息队列中获取消息。如果指定了等待时间，则任务会进入阻塞状态。消息队列收到消息了，或者等待时间超时了，该任务都会恢复为就绪状态。</li>
<li>消息队列满时，任务请求向消息队列中发送数据。如果指定了等待时间，则任务会进入阻塞状态，消息队列有空闲位置了，或者等待超时了，任务会恢复为就绪状态。如果不指定等待时间（设置为0），由于队列已经满了，发送消息请求会立刻返回错误。</li>
</ul>
<p>即，FreeRTOS的消息队列天然具有了信号量要求具备的特性：</p>
<ul>
<li><code>不可用</code>状态（即消息队列为空）下尝试获取，会让任务阻塞</li>
<li><code>可用</code>时（有数据了），会自动让等待<code>可用</code>状态的任务，恢复为就绪状态</li>
<li>多任务同时访问是安全的（信号量会涉及多个任务同时读&#x2F;写同一信号量，所以需要有多任务访问安全的特性）。</li>
</ul>
<p>因此，FreeRTOS基于现有的消息队列功能，实现了信号量功能。</p>
<h4 id="2-二值信号量："><a href="#2-二值信号量：" class="headerlink" title="2 二值信号量："></a>2 二值信号量：</h4><p>二值信号量，是广泛使用的一种信号量。任意时刻，二值信号量，要么是可用状态，要么是不可用状态。</p>
<p>FreeRTOS使用一个长度为1 的消息队列来实现二值信号量。当该消息队列中有消息时，就是信号量可用。当该消息队列中无消息时，就是信号量不可用。</p>
<h5 id="2-1-创建二值信号量"><a href="#2-1-创建二值信号量" class="headerlink" title="2.1 创建二值信号量"></a>2.1 创建二值信号量</h5><p>当我们使用API ：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">SemaphoreHandle_t semaphore = xSemaphoreCreateBinary();</span><br></pre></td></tr></table></figure>
<p>创建一个二值信号量<code>semaphore</code>时，就是创建了一个长度为1 的消息队列，并且初始状态，是没有消息的（即信号量不可用）如下图所示：信号量指针<code>semaphore</code>指向一块内存，该内存前面为消息队列的控制区域，之后为存储区，只能存储一个消息。<br><img src="/2022/12/15/FreeRTOS-use-binary-semaphore/binary-create.png"></p>
<p><code>备注：本文为了方便解释，上文以及下文图中表示信号量的消息队列中都有消息存储区。但实际的信号量代码实现中是没有消息存储区的（创建时虽然指定了队列大小n，但内部会将每个消息大小设置为0，因此消息存储区大小 n*0 = 0），因为并不需要存消息数据（也没有消息数据要存），信号量关心的是有没有消息，而不是消息本身。在消息队列控制块中有一个数据成员uxMessagesWaiting ，该成员指明当前消息队列中有几个消息，利用该成员变量即可判断消息队列是否有数据（即消息队列是否可用）。因此，不需要实际的内存来存储消息。</code></p>
<h5 id="2-2-设置二值信号量为可用状态"><a href="#2-2-设置二值信号量为可用状态" class="headerlink" title="2.2 设置二值信号量为可用状态"></a>2.2 设置二值信号量为可用状态</h5><p>信号量创建完成后，默认是不可用状态，即消息队列中是没有消息的。调用API</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">xSemaphoreGive(semaphore);</span><br></pre></td></tr></table></figure>
<p>即可将信号量<code>semaphore</code><strong>设置</strong>为有效状态，其本质是向表示信号量<code>semaphore</code>的消息队列中“放入了一条消息”。如下图所示（<code>如上文所述，实际是没放消息，只是将内部的消息计数器uxMessagesWaiting加1 了，图中是为了方便解释才画了存有消息</code>）：<br><img src="/2022/12/15/FreeRTOS-use-binary-semaphore/binary-give.png"><br><br></p>
<h5 id="2-3-获取信号量"><a href="#2-3-获取信号量" class="headerlink" title="2.3 获取信号量"></a>2.3 获取信号量</h5><p>信号量一旦处于可用状态（其中“存有消息”了），调用</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">xSemaphoreTake(semaphore, pdMS_TO_TICKS(<span class="number">1000</span>));</span><br></pre></td></tr></table></figure>
<p>就能立刻<strong>获取</strong>到信号量，该函数就会立刻返回。其原理就是从<code>semaphore</code>表示的消息队列中取走了消息（消息取走后，<code>semaphore</code>就会变成不可用状态）。如下图所示（<code>同样，下图中的取走消息是为了说明原理，实际代码中将内部的消息计数器uxMessagesWaiting减1 就行了</code>）<br><img src="/2022/12/15/FreeRTOS-use-binary-semaphore/binary-take.png"></p>
<p>但如果是在<code>semaphore不可用</code>时（即消息队列为空时），调用该api 来<strong>获取</strong><code>semaphore</code>，调用该api 的任务会阻塞在该函数内部，直到信号量可用（其它任务或中断函数中<strong>设置</strong>了信号量，即向消息队列中发送了数据），或者等待时间达到了设定的1 秒超时时间。</p>
<h4 id="3-任务和任务间使用二值信号量进行信息同步"><a href="#3-任务和任务间使用二值信号量进行信息同步" class="headerlink" title="3 任务和任务间使用二值信号量进行信息同步"></a>3 任务和任务间使用二值信号量进行信息同步</h4><p>我们以前文的例子来演示二值信号量的使用：我们创建两个任务<code>task_a</code>和<code>task_b</code>。 只有当<code>task_a</code>做完一些工作，<code>task_b</code>才能继续运行。我们使用信号量来对两个任务间的信息进行同步，<code>task_b</code>每次运行前都会先“获取”信号量，信号量不可用时，<code>task_b</code>就会阻塞， 而<code>task_a</code>每次做完工作后，就“设置”信号量，通知<code>task_b</code>可以运行了。</p>
<p><code>task_a</code>和<code>task_b</code>的代码如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">void</span> <span class="title function_">task_a</span><span class="params">( <span class="type">void</span> *pvParameters )</span> &#123;</span><br><span class="line"></span><br><span class="line">    SemaphoreHandle_t semaphore = (SemaphoreHandle_t)pvParameters;</span><br><span class="line">    <span class="keyword">for</span>(;;) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 延迟1秒，模拟 task_a 在处理一些工作</span></span><br><span class="line">        vTaskDelay(pdMS_TO_TICKS(<span class="number">1000</span>));</span><br><span class="line">        </span><br><span class="line">        SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;task_a done!\n&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 工作做完了，设置信号量，通知task_b 可以运行了</span></span><br><span class="line">        xSemaphoreGive(semaphore);</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">task_b</span><span class="params">( <span class="type">void</span> *pvParameters )</span> &#123;</span><br><span class="line">    </span><br><span class="line">    SemaphoreHandle_t semaphore = (SemaphoreHandle_t)pvParameters;</span><br><span class="line">    <span class="keyword">for</span>(;;) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 只有 task_a 做完一些工作后，通知 task_b, task_b 才能执行后续工作.</span></span><br><span class="line">        <span class="comment">// 这里“获取”信号量，如果task_a 还未设置这个信号量，task_b 就会阻塞在该函数内部，直到task_a设置信号量，或者等待超过2秒</span></span><br><span class="line">        <span class="comment">// 这里应该判断返回值，检查是超时返回还是获得信号量返回。样例为了简单，并未判断</span></span><br><span class="line">        xSemaphoreTake(semaphore, pdMS_TO_TICKS(<span class="number">2000</span>));</span><br><span class="line">        SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;task_b start runing!\n&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>main函数代码：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;FreeRTOS.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;task.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;semphr.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 创建二值信号量</span></span><br><span class="line">    SemaphoreHandle_t semaphore = xSemaphoreCreateBinary();</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span>(<span class="literal">NULL</span> != semaphore) &#123;</span><br><span class="line">        <span class="comment">// 创建两个任务</span></span><br><span class="line">        <span class="keyword">if</span> (pdPASS == xTaskCreate(task_a, <span class="string">&quot;task_a&quot;</span>, <span class="number">100</span>, semaphore, <span class="number">1</span>, <span class="literal">NULL</span>)</span><br><span class="line">            &amp;&amp; pdPASS == xTaskCreate(task_b, <span class="string">&quot;task_b&quot;</span>, <span class="number">100</span>, semaphore, <span class="number">1</span>, <span class="literal">NULL</span>))&#123;</span><br><span class="line">            </span><br><span class="line">            SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;start FreeRTOS\n&quot;</span>);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 启动内核任务调度器</span></span><br><span class="line">            vTaskStartScheduler();</span><br><span class="line">        &#125; </span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 正常启动后不会运行到这里</span></span><br><span class="line">    SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;insufficient resource\n&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span>( ;; );</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>运行结果如下所示：<code>task_b</code> 每次在 <code>task_a</code>完成后才会运行。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">start FreeRTOS</span><br><span class="line">task_a done!</span><br><span class="line">task_b start runing!</span><br><span class="line">task_a done!</span><br><span class="line">task_b start runing!</span><br><span class="line">task_a done!</span><br><span class="line">task_b start runing!</span><br><span class="line">task_a done!</span><br><span class="line">task_b start runing!</span><br></pre></td></tr></table></figure>

<h4 id="4-中断处理函数和任务间使用二值信号量进行信息同步"><a href="#4-中断处理函数和任务间使用二值信号量进行信息同步" class="headerlink" title="4 中断处理函数和任务间使用二值信号量进行信息同步"></a>4 中断处理函数和任务间使用二值信号量进行信息同步</h4><p>上面的例子中，信号量的“设置”或“获取”都是在任务代码中，FreeRTOS在中断处理函数中也可以“设置”或“获取”信号量，但需要使用带<strong>FromIS</strong>后缀的API ,中断处理函数中“设置”信号量可以使用<code>xSemaphoreGiveFromISR</code>，中断处理函数中“获取”信号量可以使用<code>xSemaphoreTakeFromISR</code>。</p>
<p>例如，下面是一个使用信号量，对中断处理函数和任务进行“事件同步”的例子。我们使用按键作为“中断源”，每当按键按下时，设置信号量。任务<code>button_pressed_handler</code>等待信号量(等待按键事件发生)，一旦信号量可用，表示等待的“事件”发生了，则做一些相关的工作。<br>其中，中断处理函数如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">extern</span> SemaphoreHandle_t semaphore;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">GPIOTE_IRQHandler</span><span class="params">(<span class="type">void</span>)</span>&#123;</span><br><span class="line"></span><br><span class="line">    BaseType_t higher_task_woken = pdFALSE;</span><br><span class="line">    <span class="comment">// 寄存器相关代码和具体硬件相关</span></span><br><span class="line">    <span class="keyword">if</span> ( NRF_GPIOTE-&gt;EVENTS_PORT == <span class="number">1</span> )&#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//中断处理函数中要清除event,不然会导致一直产生中断</span></span><br><span class="line">        NRF_GPIOTE-&gt;EVENTS_PORT = <span class="number">0</span>;    </span><br><span class="line"></span><br><span class="line">        <span class="comment">// 确认是按键按下，则设置信号量</span></span><br><span class="line">        <span class="keyword">if</span>(IS_BUTTON_PRESSED(BUTTON_1)) &#123;</span><br><span class="line">            xSemaphoreGiveFromISR(semaphore, &amp;higher_task_woken);</span><br><span class="line">            SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;in interrupt service function, button pressed\n&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 如果higher_task_woken=True，表示设置信号量操作，使得某个等待该信号可用的高优先级任务变为就绪状态了</span></span><br><span class="line">    <span class="comment">// 我们使用的是抢占式调度，只要有更高优先级的任务就绪，应该让其立刻运行。</span></span><br><span class="line">    <span class="comment">// 下面的代码就是，判断有更高优先级就绪时，就会设置任务切换中断，那么当前中断函数退出后，就会立刻触发任务切换，让最高优先级的就绪任务运行。</span></span><br><span class="line">    portYIELD_FROM_ISR(higher_task_woken);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>处理按键事件的任务代码为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">void</span> <span class="title function_">button_pressed_handler</span><span class="params">( <span class="type">void</span> *pvParameters )</span> &#123;</span><br><span class="line"></span><br><span class="line">    SemaphoreHandle_t semaphore = (SemaphoreHandle_t)pvParameters;</span><br><span class="line">    <span class="keyword">for</span>(;;) &#123;</span><br><span class="line">        <span class="comment">// 注意，使用portMAX_DELAY，表示如果信号量不可用，则会一直阻塞当前任务，直到信号量可用。</span></span><br><span class="line">        <span class="comment">// 使用portMAX_DELAY，需要在FreeRTOSConfig.h 文件中定义 INCLUDE_vTaskSuspend = 1</span></span><br><span class="line">        <span class="comment">// 正式产品代码最好使用一个超时值，这样异常发生时（例如中断源发生异常，没按预期触发），至少能获得超时错误，可以在超时错误中做一些恢复操作。</span></span><br><span class="line">        xSemaphoreTake(semaphore, portMAX_DELAY);</span><br><span class="line">        SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;in task, do something\n&quot;</span>);        </span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>Main函数实现为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;FreeRTOS.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;task.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;semphr.h&quot;</span></span></span><br><span class="line"></span><br><span class="line">SemaphoreHandle_t semaphore;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 使用二值信号量进行中断事件同步</span></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span> &#123;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 硬件相关初始化</span></span><br><span class="line">    bsp_init();</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 创建二值信号量</span></span><br><span class="line">    semaphore = xSemaphoreCreateBinary();</span><br><span class="line">    <span class="keyword">if</span>(<span class="literal">NULL</span> != semaphore) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 创建任务</span></span><br><span class="line">        <span class="keyword">if</span> (pdPASS == xTaskCreate(button_pressed_handler, <span class="string">&quot;button_pressed_handler&quot;</span>, <span class="number">100</span>, semaphore, <span class="number">1</span>, <span class="literal">NULL</span>))&#123;</span><br><span class="line">            </span><br><span class="line">            SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;start FreeRTOS\n&quot;</span>);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 启动内核调度器</span></span><br><span class="line">            vTaskStartScheduler();</span><br><span class="line">        &#125; </span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 正常启动后不会运行到这里</span></span><br><span class="line">    SEGGER_RTT_printf(<span class="number">0</span>, <span class="string">&quot;insufficient resource\n&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span>( ;; );</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>运行结果如下所示，每次按键后，就会触发任务<code>button_pressed_handler</code>执行相关工作。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">start FreeRTOS</span><br><span class="line">in interrupt service function, button pressed</span><br><span class="line">in task, do something</span><br><span class="line">in interrupt service function, button pressed</span><br><span class="line">in task, do something</span><br></pre></td></tr></table></figure>

<h4 id="为什么FreeRTOS中，有两套API分别在中断-x2F-非中断环境下使用："><a href="#为什么FreeRTOS中，有两套API分别在中断-x2F-非中断环境下使用：" class="headerlink" title="为什么FreeRTOS中，有两套API分别在中断&#x2F;非中断环境下使用："></a>为什么FreeRTOS中，有两套API分别在中断&#x2F;非中断环境下使用：</h4><p>FreeRTOS中的很多API， 可能会使得调用者任务进入阻塞态。但在中断环境中调用这些API 时，因为中断本身是和任务无关的（中断可能在任何时候发生，打断任意的任务），所以中断环境中调用这些API时， 不能让某个任务因此导致进入阻塞状态。因此，如果就使用一套API, 那么就需要在这些API 的内部实现中判断当前的调用环境是不是在中断环境中（在中断环境中和不在中断环境需要执行一些不一样的工作），这无疑为会增加API 内部实现的复杂性，同时也降低的这些API 的执行效率（因为需要做一些额外的环境判断和检查）。</p>
<p>因此，FreeRTOS针对这些API，直接实现了两套API，分别在中断和非中断环境中使用。这样，每套API的调用环境是确定的，内部实现可以更简单，高效。<br><br></p>
<br>
ps：需要注意文章代码中的日志输出函数，产品代码中如果需要使用的话，需要考虑线程安全性（多任务安全性），因为中断/任务切换可能发生在另一个任务正在输出日志但还未输出完的时候，这就可能造成日志错乱

<br>
<br>
FreeRTOS交流QQ群-663806972

<br>

    </div>

    
    
    

    <footer class="post-footer">
          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>feng xun
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/" title="FreeRTOS-使用二值信号量">http://fengxun2017.github.io/2022/12/15/FreeRTOS-use-binary-semaphore/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2022/12/14/FreeRTOS-use-queueset/" rel="prev" title="FreeRTOS-使用消息队列集合">
                  <i class="fa fa-chevron-left"></i> FreeRTOS-使用消息队列集合
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2022/12/17/FreeRTOS-use-counting-semaphore/" rel="next" title="FreeRTOS-使用计数信号量">
                  FreeRTOS-使用计数信号量 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">feng xun</span>
</div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">552k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">11:30</span>
  </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
